package cn.edu.sdjzu.knoverse.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.edu.sdjzu.knoverse.model.vo.ranking.CaseRankingVO;
import cn.edu.sdjzu.knoverse.model.vo.result.OverviewDataVO;
import cn.edu.sdjzu.knoverse.model.vo.result.Result;
import cn.edu.sdjzu.knoverse.service.OverviewService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 首页概览数据
 */
@RestController
@RequestMapping("/overview")
@Tag(name = "首页概览数据接口", description = "提供首页数据展示相关接口")
@RequiredArgsConstructor
@SaCheckLogin
public class OverviewController {

    private final OverviewService overviewService;

    /**
     * 获取首页概览数据
     * @return 概览数据
     */
    @GetMapping("/data")
    @Operation(summary = "获取首页概览数据", description = "获取节点总数、关系总数、文件总数、案例总数等统计数据")
    public Result<OverviewDataVO> getOverviewData() {
        return Result.success(overviewService.getOverviewData());
    }
    
    /**
     * 获取案例点击量排行榜
     * @return 案例排行榜
     */
    @GetMapping("/case/ranking")
    @Operation(summary = "获取案例点击量排行榜", description = "获取案例点击量前十的排行榜数据")
    public Result<List<CaseRankingVO>> getCaseRanking() {
        return Result.success(overviewService.getCaseRanking());
    }
}
